package com.link.wseller.serive.impl;

import com.link.wseller.domain.ProductCategory;
import com.link.wseller.mapper.impl.ProductCategoryMapperImpl;
import com.link.wseller.serive.ProductCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商品类目
 */
@Service
@Slf4j
public class ProductCategoryServiceImpl implements ProductCategoryService {

    @Autowired
    private ProductCategoryMapperImpl categoryMapper;

    @Override
    public ProductCategory findOne(Integer categoryId) {
        return categoryMapper.selectByPrimaryKey(categoryId);
    }

    @Override
    public List<ProductCategory> findAll() {
        return categoryMapper.findAll();
    }

    @Override
    public List<ProductCategory> findByCategoryTypeIn(List<Integer> categoryTypeList) {

        String typeList = StringUtils.join(categoryTypeList, ',');
        log.info("typeList: {}", typeList);
        return categoryMapper.findByCategoryTypeIn(typeList);
    }

    @Override
    public int save(ProductCategory productCategory) {
        return categoryMapper.insert(productCategory);
    }
}
